/****************************************
 * Copyright (c) 2015 NiuWa.
 * All rights reserved.
 * Created on 2015年4月5日
 * 
 * Contributors:
 * 	lijian - initial implementation
 ****************************************/
package com.niuwa.p2p.core.mvc.entity;

import java.io.Serializable;
import java.util.List;

/**
 * @title 前台分页使用
 *
 * @author lijian
 * @version 1.0
 * @created 2015年4月5日
 */
public class PageComponent<T> implements Serializable {
	
	private static final long serialVersionUID = -3953772369286066983L;
	public static final Integer DEFAULT_PAGE_SIZE = Integer.valueOf(10);//默认页大小
	public static final Integer DEFAULT_PAGE_INDEX = Integer.valueOf(1);//默认第一页
	
	/**页码[当前页]*/
	private int pageIndex;

	/** 每页大小 */
	private int pageSize;
	
	/**总条数*/
	private int recordCount;
	
	/**页信息*/
	private List<T> pageResult;
	
	public PageComponent() {
		super();
	}
	
	public PageComponent(int pageIndex,int pageSize){
		this.pageIndex = pageIndex;
		this.pageSize = pageSize;
	}
	
	
	public PageComponent(int pageIndex,int pageSize,
			int recordCount, List<T> pageResult) {
		super();
		setPageIndex(pageIndex);//  初始化    or 设置当前页
		setPageSize(pageSize);//每页大小
		this.recordCount = recordCount; //总条数
		this.pageResult = pageResult;
	}

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		if (pageIndex < 1) {
			this.pageIndex = DEFAULT_PAGE_INDEX;//默认第一页
		} else {
			this.pageIndex = pageIndex;
		}
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		if (pageSize < 1) {
			this.pageSize = DEFAULT_PAGE_SIZE;//默认每页10
		} else {
			this.pageSize = pageSize;
		}
	}


	public List<T> getPageResult() {
		return pageResult;
	}


	public void setPageResult(List<T> pageResult) {
		this.pageResult = pageResult;
	}


	public int getRecordCount() {
		return recordCount;
	}


	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}
	
}
